package io.renren.modules.sys.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.sys.dao.AgentShopAdminDao;
import io.renren.modules.sys.entity.AgentShopAdminEntity;
import io.renren.modules.sys.service.AgentShopAdminService;


@Service("agentShopAdminService")
public class AgentShopAdminServiceImpl extends ServiceImpl<AgentShopAdminDao, AgentShopAdminEntity> implements AgentShopAdminService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String status = (String) params.get("status");
        String adminName = (String)params.get("adminName");
        String adminParent = (String)params.get("adminParent");
        String adminBusParent = (String)params.get("adminBusParent");
        String adminPhone = (String)params.get("adminPhone");
        IPage<AgentShopAdminEntity> page = this.page(
                new Query<AgentShopAdminEntity>().getPage(params),
                new QueryWrapper<AgentShopAdminEntity>()
                        .eq(StringUtils.isNotBlank(status), "STATUS",status)
                        .like(StringUtils.isNotBlank(adminName),"ADMIN_NAME", adminName)
                        .eq(StringUtils.isNotBlank(adminParent), "ADMIN_PARENT" , adminParent)
                        .eq(StringUtils.isNotBlank(adminBusParent), "ADMIN_BUS_PARENT" ,adminBusParent)
                        .like(StringUtils.isNotBlank(adminPhone), "ADMIN_PHONE" ,adminPhone)
        );

        return new PageUtils(page);
    }

}
